import 'package:flutter/material.dart';

class HomeNav extends StatefulWidget {
  const HomeNav({super.key});

  @override
  State<HomeNav> createState() => _HomeNavState();
}

class _HomeNavState extends State<HomeNav> {
  final List _navList = [
    {'title': '我的房屋', 'name': 'house', 'icon': 'assets/images/house_nav_icon@2x.png'},
    {'title': '我的保修', 'name': 'repair', 'icon': 'assets/images/repair_nav_icon@2x.png'},
    {'title': '访客登记', 'name': 'visitor', 'icon': 'assets/images/visitor_nav_icon@2x.png'}
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.all(10),
      padding: const EdgeInsets.only(top: 10, bottom: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: _navList.map((item) {
          return GestureDetector(
            onTap: () {
              if (item["name"] == 'house') {
                Navigator.pushNamed(context, '/houseList');
              } else if (item["name"] == 'repair') {
                Navigator.pushNamed(context, '/repairList');
              } else if (item["name"] == 'visitor') {
                Navigator.pushNamed(context, '/visitorList');
              }
            },
            child: Column(
              children: [
                Image.asset(item["icon"], width: 30, height: 30),
                const SizedBox(height: 5),
                Text(item["title"]),
              ],
            ),
          );
        }).toList(),
      ),
    );
  }
}
